#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
    int minimumTimeToInitialState(string word, int k) {
        int n=word.size();
        vector<int> z(n);
        for(int i=1,l=0,r=0;i<n;i++)
        {
            if(i<=r&&z[i-l]<r-i+1)
                z[i]=z[i-l];
            else
            {
                z[i]=max(0,r-i+1);
                while(i+z[i]<n&&word[z[i]]==word[i+z[i]]) z[i]++;
            }
            if(z[i]+i-1>r) l=i,r=i+z[i]-1;
        }
        int idx=0;
        for(int i=0;i<n;i+=k)
        {
            if(i+z[i]==n)
            {
                idx=i;
                break;
            }
        }
        return idx/k==0?ceil(1.0*n/k):idx/k;
    }
};


int main()
{
    string s="abacaba";
    Solution so;
    so.minimumTimeToInitialState(s,3);
    return 0;
}